<template>
	<view class="content">
		<view class="avatar-wrap">
			<view class="userInfo" v-if="isLogin">
				<navigator url="../fillInfo/fillInfo" class="text-center">
					<view class="avatar">
						<image src="../../static/image/default-face.png" mode="widthFix" style="width: 120upx;height: 120upx;"></image>
					</view>
					<text class="nickname">
						{{userInfo.AAC003}}
					</text>
				</navigator>
			</view>
			<view class="" v-else>
				<navigator url="../registerLogin/registerLogin" class="text-center">
					<view class="avatar">
						<image src="../../static/image/default-face.png" mode="widthFix" style="width: 120upx;height: 120upx;"></image>
					</view>
					<text class="nickname">
						注册/登录
					</text>
				</navigator>
			</view>
		</view>
		<uni-list class="list">
			<uni-list-item title="备案审批信息查询" @click="goTo('../records/records')"></uni-list-item>
			<uni-list-item title="住院结算信息查询" @click="goTo('../settlement/settlement')"></uni-list-item>
			<uni-list-item title="人员参保信息查询" @click="goTo('renyuan')"></uni-list-item>
			<uni-list-item title="完善个人参保信息" @click="goTo('../fillInfo/fillInfo')"></uni-list-item>
			<uni-list-item title="退出" v-if="isLogin" @click="logout()"></uni-list-item>
		</uni-list>
	</view>
</template>

<script>
	import uniList from '@/components/uni-list/uni-list.vue';
	import uniListItem from '@/components/uni-list-item/uni-list-item.vue';
	export default {
		components: {
			uniList,
			uniListItem
		},
		data() {
			return {
				isLogin: false,
				isFillInfo:false,
				userInfo: {
					AAC003: ''
				}
			}
		},
		methods: {
			logout() {
				const that = this
				uni.showModal({
					title: '询问',
					content: '您确定要退出吗？',
					cancelText: '取消',
					confirmText: '确定',
					success: (e) => {
						if (e.confirm) {
							uni.removeStorageSync("userInfo");
							uni.setStorageSync('isLogin', false);
							that.isLogin = false;
						}
					}
				})
			},
			goTo(url) {
				if (!this.isLogin) {
					var that = this;
					uni.showToast({
						title: '请登录',
						icon: 'none',
						duration: 2000,
						success: function() {
							if(that.$common.sys.toSSOLogin){
								setTimeout(function() {
									window.location.assign(that.$common.sys.ssoUrl+"="+that.$common.sys.redirectUri);
								}, 2000)
								
							}else{
								setTimeout(function() {
									uni.navigateTo({
										url: '../registerLogin/registerLogin'
									})
								}, 2000)
							}

						}
					});
					return false;
				}
				if(!this.isFillInfo){
					uni.showToast({
						title: '请完善个人参保信息',
						icon: 'none',
						duration: 2000,
						success: function() {
							setTimeout(function() {
								uni.navigateTo({
									url: "../fillInfo/fillInfo",
								})
							}, 2000)
					
						}
					});
					return false;
				}
                if(url == 'renyuan'){
					if(this.userInfo.AAE140 == '31'){
						url = "../renyuan/zg_index"
					}else{
						url = "../renyuan/renyuan"
					}
					
				}
				uni.navigateTo({
					url: url
				})
			},
		},
		onShow() {
			this.isLogin = this.$common.sys.toSSOLogin?this.$common.sys.toSSOLogin:uni.getStorageSync('isLogin');
			this.userInfo = uni.getStorageSync('userInfo');
			this.isFillInfo =  this.$common.isFillInfo(this.userInfo);
			console.info(this.isFillInfo)
		}
	}
</script>

<style>
	.avatar-wrap {
		height: 360upx;
		display: flex;
		justify-content: center;
		align-items: center;
		background: url() no-repeat center/100% 100%;

	}

	.userInfo {
		text-align: center;
	}

	.avatar {
		width: 120upx;
		height: 120upx;
		margin: 0 auto 10upx;
		background-color: #fff;
		border-radius: 50%;
		overflow: hidden;
	}

	.nickname {
		color: #fff;
		font-size: 13px;
	}
</style>
